<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'fileManage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
 <link rel="stylesheet" type="text/css" href="jsTools/bootstrap-3.3.7-dist/css/bootstrap.min.css">
	<script type="text/javascript" src="jsTools/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	
	<link rel="stylesheet" type="text/css" href="jsTools/jquery-easyui-1.5.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="jsTools/jquery-easyui-1.5.1/themes/icon.css">
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/jquery.min.js"></script>
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="jsTools/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js" charset="utf-8"></script>
  </head>
  
  <body>
    <div class="container">
   		<div class="row clearfix">
	
   				<div class="col-sm-2" >
   				
   				<ul class="list-unstyled list-inline">
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" id="upload">上传文件</a></li>
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="look">文件列表</a></li>
   					<li><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" id="download">下载文件</a></li>
   				</ul>
				
   				</div>
   		<div class="col-sm-10">
   				<div id="divlook">
   				
   				<table class="table table-bordered table-hover table-condensed">
				<thead>
					<tr><th>文件标题</th><th>文件名字</th><th>文件类型</th><th>文件大小</th><th>删除文件</th></tr>
				</thead>	
				<tbody>	
				</tbody>
				</table>
   				</div>
   				<div id="divUpload" >
   						<form id="addform" action="fileManage!insert.action" enctype="multipart/form-data" method="post">
   				<table class="table table-bordered table-hover table-condensed" >
				<thead>
					
				<tbody>
					<tr>
						<td>
							文件标题
						</td>
						<td >
							<input name="title" type="text"  class="easyui-textbox" data-options="required:true">
						</td>						
					</tr>
					<tr class="success">
						<td>
							选择文件
						</td>
						<td>
							<input type="file"  name="file">
						</td>
						
					</tr>
				</tbody>
			</table>  
				<div  class="col-sm-6 col-sm-offset-3"><button   type="submit" class="btn btn-primary btn-default pull-left" ><span class=" glyphicon glyphicon-plus"></span>上传</button>
				<button  type="reset" class="btn  btn-default pull-right">清空</button></div>  						
				</form>
				
				</div>
				
   		<div id="divDownload" class="col-sm-4 col-sm-offset-4">
   		<form action="fileManage!oneSelect.action" method="post">
   		<div class="col-sm-12 "><input type="text" class="easyui-textbox" data-options="required:true" name="title"><button  class="btn btn-link" type="submit"><span class=" glyphicon glyphicon-search"></span>查找</button></div>		
		</form>		
			</div>	
   					</div>
   				</div>
   		</div>  	
  </body>
  <script type="text/javascript">
  	 $(function(){$("#divUpload").css("display","none");$("#divDownload").css("display","none");
  		$.get("fileManage!select.action",function(data){ var s=JSON.parse(data);
  						for(var i=0;i<s.length;i++)
  						{
  							$("#divlook table tbody").append("<tr><td>"+s[i].title+"</td><td>"+s[i].name+"</td><td>"+s[i].contentType+"</td><td>"+s[i].size+"</td><td><a href='fileManage!delete.action?title="+s[i].title+"'>删除文件</a></td></tr>");
  						}
  		});
  
  });
  $("#look").click(function() {$("#divlook table tbody").empty();$("#divlook").css("display","block");$("#divUpload").css("display","none");$("#divDownload").css("display","none");
  	$.get("fileManage!select.action",function(data){ var s=JSON.parse(data);
  						for(var i=0;i<s.length;i++)
  						{																				
  							$("#divlook table tbody").append("<tr><td>"+s[i].title+"</td><td>"+s[i].name+"</td><td>"+s[i].contentType+"</td><td>"+s[i].size+"</td><td><a href='fileManage!delete.action?title="+s[i].title+"'>删除文件</a></td></tr>");
  						}
  		});
  	});
  	$("#upload").click(function() {$("#divlook").css("display","none");$("#divUpload").css("display","block");$("#divDownload").css("display","none");});
	$("#download").click(function() {$("#divlook").css("display","none");$("#divUpload").css("display","none");$("#divDownload").css("display","block");});
  	
  	
  </script>
</html>
